m = int(input())
l = [0]*5
for i in range(m):
a, b = map(int, input().split())
l[a-1] += 1
l[b-1] += 1
if l.count(2) == 5:
print('FAIL')
else:
print('WIN')
#include <bits/stdc++.h>
using namespace std;
bool bsf(vector<int> adj[],int vis[],int n,int p)
{
queue<pair<pair<int,int>,int>> q;
q.push({{n,p},0});
unordered_map<int,int> m;
while(!q.empty())
{
int n=q.front().first.first;
int p=q.front().first.second;
int l=q.front().second;
q.pop();
for(auto it:adj[n])
{
if(!vis[it])
{
q.push({{it,n},l+1});
vis[it]=1;
}
else
{
if(it!=p&&l==1&&m[it]==1)
return true;
}
}
m[n]=1;
}
return false;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
vector<int> adj[6];
vector<int> nonadj[6];
for (int i = 1; i < 6; i++)
{
for (int j = 1; j < 6; j++)
{
if(i!=j)
nonadj[i].push_back(j);
}
}
int m;
cin>>m;
for (int i = 0; i < m; i++)
{
int u,v;
cin>>u>>v;
adj[u].push_back(v);
adj[v].push_back(u);
auto pos=find(nonadj[u].begin(),nonadj[u].end(),v);
nonadj[u].erase(pos);
auto pos2=find(nonadj[v].begin(),nonadj[v].end(),u);
nonadj[v].erase(pos2);
}
// for(int i=1;i<6;i++)
// {
// for(auto it:nonadj[i])
// cout<<it<<" ";
// cout<<endl;
// }
for(int i=1;i<6;i++)
{
// if(!vis[i])
{
int vis[6]={0};
vis[i]=1;
if(bsf(adj,vis,i,-1))
{
cout<<"WIN"<<endl;
return 0;
}
}
}
for(int i=1;i<6;i++)
{
// if(!vis2[i])
{
int vis2[6]={0};
vis2[i]=1;
if(bsf(nonadj,vis2,i,-1))
{
cout<<"WIN"<<endl;
return 0;
}
}
}
cout<<"FAIL"<<endl;
return 0;
}
1302. Deepest Leaves Sum | 1209. Remove All Adjacent Duplicates in String II |
994. Rotting Oranges | 983. Minimum Cost For Tickets |
973. K Closest Points to Origin | 969. Pancake Sorting |
967. Numbers With Same Consecutive Differences | 957. Prison Cells After N Days |
946. Validate Stack Sequences | 921. Minimum Add to Make Parentheses Valid |
881. Boats to Save People | 497. Random Point in Non-overlapping Rectangles |
528. Random Pick with Weight | 470. Implement Rand10() Using Rand7() |
866. Prime Palindrome | 1516A - Tit for Tat |
622. Design Circular Queue | 814. Binary Tree Pruning |
791. Custom Sort String | 787. Cheapest Flights Within K Stops |
779. K-th Symbol in Grammar | 701. Insert into a Binary Search Tree |
429. N-ary Tree Level Order Traversal | 739. Daily Temperatures |
647. Palindromic Substrings | 583. Delete Operation for Two Strings |
518. Coin Change 2 | 516. Longest Palindromic Subsequence |
468. Validate IP Address | 450. Delete Node in a BST |